//
//  UserModel.m
//  ZZLC
//
//  Created by 杨春至 on 2017/12/18.
//  Copyright © 2017年 ZhongZeng. All rights reserved.
//

#import "UserModel.h"

@implementation UserModel


+(NSDictionary *)userDic{
    

        NSData *data = [[NSUserDefaults standardUserDefaults]objectForKey:K_USER_MODEL];
    if ([data isKindOfClass:[NSData class]]) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        return dict;
    }
    else
    {
        return nil;
    }
    
}
+ (NSString *)userName
{
    NSDictionary *userDic = [self userDic];
    NSString *userID = [userDic objectForKey:@"username"];
    return userID;
}
+ (NSString *)authorization
{
    NSDictionary *userDic = [self userDic];
    NSString *userID = [userDic objectForKey:@"authorization"];
    return userID;
}
+ (BOOL)isLogin
{
    NSDictionary *userDic = [self userDic];
    NSString *userID = [userDic objectForKey:@"username"];
    if (userID) {
        return YES;
    }
    else
    {
        return false;
    }
}
+ (BOOL)isAuthorization
{
    NSDictionary *userDic = [self userDic];
    NSString *authorizationID = [userDic objectForKey:@"authorization"];
    if (authorizationID) {
        return YES;
    }
    else
    {
        return false;
    }
}
+ (void)clearData{
    [[NSUserDefaults standardUserDefaults]removeObjectForKey:K_USER_MODEL];
    [[NSUserDefaults standardUserDefaults]synchronize];
}
@end
